Skip to content

fix: apply cancel_timeout when canceling a queued sql.batch - #1336

Open
pcbeingused333 wants to merge 2 commits into
porsager:masterfrom
pcbeingused333:fix/cancelbatch-cancel-timeout
Open

pcbeingused333 wants to merge 2 commits into
porsager:masterfrom
pcbeingused333:fix/cancelbatch-cancel-timeout

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Related to #1318 (same area: cancel_timeout and sql.batch), but a different path: that PR clears a leftover timer after a batch settles; this one covers a batch that has not started yet.

cancel() on a plain query that is already sent but queued behind another one calls quiet(x), so the configured cancel_timeout applies. cancelBatch did not: for a sent batch that is not first in line it only stored the cancel promise handlers. If the query ahead never finishes (for example pg_sleep with a long duration), neither the batch nor its cancel() ever settles, even with cancel_timeout set (documented in the README).

cancelBatch now calls quiet(x) before waiting, matching cancel(). No new timeout is introduced; it restores the existing one.

Test: tests/unit/cancel.js uses the simulated server and cancel_timeout: 0.1, with a long-running query ahead of a canceled sql.batch. Before the change the batch and the cancel promise stay pending (false,false); after, both settle (true,true). Added a CHANGELOG entry under Unreleased.

This change was prepared, and the tests above were run, with the assistance of an AI coding tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant